<template>
  <div class="btns">
    <!-- <el-button @click="open" v-bind="$attrs" v-if="showBtn">
      <slot></slot>
    </el-button> -->
    <el-dialog
      :close-on-click-modal="false"
      :title="title"
      :visible.sync="visible"
      @close="onClose"
      v-loading="loading"
      append-to-body
      width="500px"
    >
      <el-form :model="form" label-width="150px" size="small">
        <el-form-item label="员工登录账号：">{{
          form.userAccount
        }}</el-form-item>
        <el-form-item label="姓名：">{{ form.employeeName }}</el-form-item>
        <el-form-item label="登录密码：">**********</el-form-item>
        <el-form-item label="角色：">{{ form.roleName }}</el-form-item>
        <el-form-item label="状态：">{{
          form.accountStatus === 0 ? "启用" : "禁用"
        }}</el-form-item>
        <el-form-item label="部门：" v-show="form.secondDeptName">{{ form.secondDeptName }}</el-form-item>
        <el-form-item label="联系电话：">{{ form.mobile }}</el-form-item>

        <el-form-item label="创建时间：">{{ form.createTime }}</el-form-item>
      </el-form>
      <div slot="footer">
        <el-button @click="visible = false" size="small">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    showBtn: {
      type: Boolean,
      default: true
    }
  },
  data() {
    return {
      loading: false,
      visible: false,
      form: {},
      title: "账户信息"
    };
  },
  methods: {
    onClose() {
      // this.form = defaultForm()
    },
    async open() {
      this.visible = true;
      this.getData();
    },
    async getData() {
      this.loading = true;
      const [err, res] = await this.$Api.getApi("users").get("myInfo", {});
      this.loading = false;
      if (!err && res) {
        this.form = res;
      }
    }
  }
};
</script>
